<script setup>
import { ref,onMounted } from "vue";
import axios from "axios"
import {ElMessage} from "element-plus"
let obj=ref({
  phone:"",
  password:""
})
const onSubmit=()=>{
  axios.post(`http://127.0.0.1:8000/user/users/get_user/`,obj.value)
  .then(res=>{
    console.log(res)
    if (res.data.code==200){
      ElMessage.success("登录成功")
      obj.value={
        phone:"",
        password:""
      }
    }
    if (res.data.code==202){
        ElMessage.error("手机号不存在")
        obj.value={
        phone:"",
        password:""
      }
    }
    if(res.data.code==400){
      ElMessage.error("密码错误")
      obj.value={
        phone:"",
        password:""
      }
    }
  })

}
</script>

<template>
    <el-form-item label="用户名" style="width: 240px;">
      <el-input v-model="obj.phone" />
    </el-form-item>
    <el-form-item label="密码" style="width: 240px;">
      <el-input v-model="obj.password" />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">登录</el-button>
      <el-button>注册</el-button>
    </el-form-item>
</template>

<style scoped>

</style>
